﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
using DBA.Data;
using DBA.Data.ADO;
using DBA.Model;
using DBA.Common;

namespace Demo
{
    public partial class demo_page3Modify : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack) return;
            BindDate();
        }

        DataAccessLibrary dal = CommonQuery.DataAccessLibrary;

        private void BindDate()
        {
            string sql = "";
            ViewState["UserID"] = Request.Params["id"].Trim();
            Test_UserInfo userInfo = new Test_UserInfo();
            userInfo.UserID = ConvertHelper.ToInt(ViewState["UserID"]);
            userInfo = dal.ModifyData.GetEntity<Test_UserInfo>(userInfo);
            txtAddress.Text = userInfo.Address;
            txtEmail.Text = userInfo.Email;
            txtIDCard.Text = userInfo.IDcard;
            txtPhone.Text = userInfo.Phone;
            txtPostalCode.Text = userInfo.PostalCode;
            txtUserName.Text = userInfo.UserName;
            txtMobile.Text = userInfo.Mobile;

        }

        protected void btnSave_Click(object sender, EventArgs e)
        {

        }

        protected void lbtn_Save_Click(object sender, EventArgs e)
        {
            Test_UserInfo userInfo = new Test_UserInfo();
            userInfo.UserName = txtUserName.Text.Trim();
            userInfo.Address = txtAddress.Text.Trim();
            userInfo.IDcard = txtIDCard.Text.Trim();
            userInfo.Phone = txtPhone.Text.Trim();
            userInfo.Mobile = txtMobile.Text.Trim();
            userInfo.Email = txtEmail.Text.Trim();
            userInfo.PostalCode = txtPostalCode.Text.Trim();
            userInfo.UserID = ConvertHelper.ToInt(ViewState["UserID"]);
            if (dal.ModifyData.Update<Test_UserInfo>(userInfo)!="0")
            {
                ScriptManager.RegisterStartupScript(this, base.GetType(), "updateOk" + System.Guid.NewGuid().ToString(), "Public.OpertAlert('数据修改成功',true);", true);
            }
            else
            {
            }
        }
    }
}